package com.winchain.chainbill.bill.biz.send.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbStats;
import com.winchain.chainbill.bill.base.service.CbStatsService;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillStatsSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<? extends Object>> {
	@Autowired
	private CbStatsService cbStatsService;

	public void onApplicationEvent(BillEvent<? extends Object> t) {
		CbStats stats = t.getBill().getStats();
		if (stats != null) {
			this.cbStatsService.saveOrUpdate(stats);
		}
	}
}
